package com.appspot.widget.setting;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.widget.base.BaseServlet;

public class SettingServiceImpl extends BaseServlet {

	private static final long serialVersionUID = 186661279067052579L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String path = this.getServletContext().getRealPath(
				"/WEB-INF/setting/global.properties");
		Properties prop = new Properties();
		prop.load(new FileInputStream(path));
		String sw = req.getParameter("sw");
		prop.setProperty("switch", sw);
		resp.getWriter().write("Settings saved!");
	}

}
